﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;

namespace Mozlite.WebUI.Mvc4.Configuration
{
    /// <summary>
    /// 路由配置。
    /// </summary>
    public class RouteConfig
    {
        /// <summary>
        /// 注册路由。
        /// </summary>
        /// <param name="routes">路由集合实例对象。</param>
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
            routes.Register("ValidCode", "ValidCode/{key}/{width}x{height}", new { controller = "Home", action = "ValidCode" });
            routes.Register("Resourcejs", "resourcejs", new { controller = "Home", action = "Resourcejs" });
            routes.Register("Upload", "upload", new { controller = "FileStorage", action = "Upload" });
            routes.Register("Browser", "browser", new { controller = "FileStorage", action = "Browser" });
            routes.Register("Download", "download", new { controller = "FileStorage", action = "Download" });
            routes.RegisterDB();
            routes.RegisterDll();
            routes.Register("Default", "{p0}/{p1}/{p2}/{p3}/{p4}/{p5}/{p6}/{p7}/{p8}/{p9}", new
            {
                controller = "Home",
                action = "Index",
                p0 = UrlParameter.Optional,
                p1 = UrlParameter.Optional,
                p2 = UrlParameter.Optional,
                p3 = UrlParameter.Optional,
                p4 = UrlParameter.Optional,
                p5 = UrlParameter.Optional,
                p6 = UrlParameter.Optional,
                p7 = UrlParameter.Optional,
                p8 = UrlParameter.Optional,
                p9 = UrlParameter.Optional
            });
            //routes.Register("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
        }
    }
}